<script>
   $(document).ready(function(){
       $("#name").keyup(function(){
           var name = $(this).val();
           if(name==""){
        	   var str="<font color='red'>&nbsp;型号名不能空！</font>";
               $("#name_notice").html('');
               $("#name_notice").html(str);
           }else{
	           $.ajax({
		    	   type: "POST",
		    	   url: "<?php echo base_url();?>model/auth",
		    	   data: "name="+name+"&type=mod",
		    	   success: function(msg){
		    		    if(msg>=1){
	                        var str="<font color='red'>&nbsp;此型号名已经存在，请更改！</font>";
	                    }else{
	                    	var str="<font color='green'>&nbsp;此型号名可使用！</font>";
	                    }
	                    $("#name_notice").html('');
	                    $("#name_notice").html(str);
		    	   }
		    	}); 
           }
       })
       
       $("#name").blur(function(){
           var name = $(this).val();
           if(name==""){
        	   var str="<font color='red'>&nbsp;型号名不能空！</font>";
               $("#name_notice").html('');
               $("#name_notice").html(str);
           }else{
	           $.ajax({
		    	   type: "POST",
		    	   url: "<?php echo base_url();?>model/auth",
		    	   data: "name="+name+"&type=mod",
		    	   success: function(msg){
		    		   if(msg>=1){
	                       var str="<font color='red'>&nbsp;此型号名已经存在，请更改！</font>";
	                   }else{
	                   	   var str="<font color='green'>&nbsp;此型号名可使用！</font>";
	                   }
	                   $("#name_notice").html('');
	                   $("#name_notice").html(str);
		    	   }
		    	}); 
           }	
       })

       $("#submit").click(function(){
           var name = $("#name").val();
           if(name==""){
        	   var str="<font color='red'>&nbsp;型号名不能空！</font>";
               $("#name_notice").html('');
               $("#name_notice").html(str);
               return false;
           }
         })
   })
</script>
		<div id="center-column">
			<div class="top-bar">
				<a href="<?php echo  base_url();?>model/model_add" class="button">新增</a>
				<h1>Contents</h1>
				<div class="breadcrumbs"><a href="#">首页</a> /<?php echo anchor('model/index','添加型号');?></div>
			</div>
			
		  <div class="table add_table">
				
				
				<table class="listing form" cellpadding="0" cellspacing="0">
				  <?php if(isset($id)){echo form_open('model/model_edit/'.$id);}else{echo form_open('model/model_add');}?>
					<tr>
						<th  colspan="2"  align="center"><?php if(isset($id)){?>编辑型号<?php }else{?>新增型号<?php }?></th>
					</tr>
					<tr>
						<td class="first" width="172"><strong>型号：</strong></td>
						<td class="last"><input type="text" class="text" name="name" value="<?php if(isset($id)){echo $mod->name;}?>" id="name"/><span id="name_notice"></span></td>
					</tr>
					<tr class="bg">
						<td class="first"><strong>描述：</strong></td>
						<td class="last"><textarea name="des" cols="80" rows="5"><?php if(isset($id)){echo $mod->des;}?></textarea></td>
					</tr>
					<tr class="bg">
						<td colspan="2" style="text-align:center;"><input type="submit" value="提交" class="button" id="submit"/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<input type="button" value="返回" class="button" onclick="location.href='<?php echo site_url()?>model/index'" /></td>			
					</tr>
				</form>	
				</table>
	        <p>&nbsp;</p>
		  </div>
		</div>
	</div>
	<div id="footer"></div>
</div>



</body>
</html>
